package net.osc.web;

import java.sql.Timestamp;
import java.util.Date;

import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ser.CustomSerializerFactory;

/**
 * 协助特殊类型在json转换过程中的格式化<br>
 * 
 * @author <a href=mailto:wu.peng@starit.com.cn>wu.peng</a> 2012-7-20
 * 
 */
public class CommonObjectMapper extends ObjectMapper {

	public CommonObjectMapper() {
		DefaultJsonDateSerializer jsonDateSer = new DefaultJsonDateSerializer();
		CustomSerializerFactory sf = new CustomSerializerFactory();
		sf.addSpecificMapping(Date.class, jsonDateSer);
		sf.addSpecificMapping(Timestamp.class, jsonDateSer);
		sf.addSpecificMapping(java.sql.Date.class, jsonDateSer);
		
		this.setSerializerFactory(sf);
	}

}
